"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var express = require("express");
var router = express.Router();
var Choose;
(function (Choose) {
    Choose[Choose["wife"] = 0] = "wife";
    Choose[Choose["mather"] = 1] = "mather";
})(Choose || (Choose = {}));
var MySql = /** @class */ (function () {
    function MySql() {
        this.host = "initValue"; // 只能是可读, not change, first set initial value
        this.host = '9999'; // readonly property can be constructor  change.
    }
    MySql.prototype.connect = function (pwd, uname) { };
    return MySql;
}());
var server = new MySql();
console.log(server.host);
function question(choose) {
    console.log("\u4F60\u5AB3\u5987\u548C\u4F60\u6BCD\u4EB2\u540C\u65F6\u6389\u8FDB\u6C34\u91CC\u4F60\u5148\u6551\u54EA\u4E2A?");
    console.log("i will rescue + " + choose);
    return choose;
}
function somefunc(_a) {
    var _b = _a === void 0 ? { x: 2, y: 2, z: 8 } : _a, _c = _b.x, x = _c === void 0 ? 0 : _c, _d = _b.y, y = _d === void 0 ? 0 : _d, _e = _b.z, z = _e === void 0 ? 3 : _e;
    console.log(z);
}
var Person = /** @class */ (function () {
    function Person() {
        this.saveMonth = true;
    }
    Person.prototype.answer = function () {
        if (this.saveMonth === false) {
            return Choose.wife;
        }
        return Choose.mather;
    };
    Person.prototype.hello = function () {
        console.log("hello i am + " + this.name);
    };
    Person.prototype.emty = function () { };
    Person.prototype.down = function () {
        // 死循环
        while (true) { }
    };
    return Person;
}());
var PropertyObj = {
    IdCard: '99999',
    0: 20,
    age: ["false", 'ssss']
};
var MyFunc = function (options) {
    console.log(options);
    return '';
};
MyFunc("\u63CF\u8FF0\u63A5\u53E3\u51FD\u6570\u52A0\u8F7D\u5B8C\u6210...");
var MyDateClass = /** @class */ (function () {
    function MyDateClass(year, month, day) {
        this.year = year;
        this.month = month;
        this.day = day;
        console.log('描述可实例化代码完成...');
        return this;
    }
    return MyDateClass;
}());
function getDate(Class, _a) {
    var year = _a.year, month = _a.month, day = _a.day;
    return new Class(year, month, day);
}
getDate(MyDateClass, { year: '2018', month: '12', day: '1' });
function getCounter() {
    var counter = function (start) { console.log('start is ' + start); };
    counter.interval = 123;
    counter.reset = function () { return console.log('reset is finish.'); };
    return counter;
}
var c = getCounter();
c(10);
c.reset();
c.interval = 11;
var Add1;
Add1 = function add2(x, y) {
    return x + y;
};
// 不用interface
var Add3 = function (x, y) {
    return x + y;
};
// 可选和默认值
var add10 = function (x) {
    var y = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        y[_i - 1] = arguments[_i];
    }
    console.log(x);
};
add10(1, 2, 3, 45, 6, 7);
var arr = [1, 23, 4];
var arr2 = arr.concat([33, 55]);
var arr3 = [33, 55].concat(arr);
// 泛型
var one2 = function (a) { return a[0]; };
one2([1, 2, 3, 'sss']);
var one3 = function (a) {
    return a[0];
};
one3([1, 2, 3]);
// 类泛型
var ClassPerson = /** @class */ (function () {
    function ClassPerson() {
    }
    return ClassPerson;
}());
var cp = new ClassPerson();
function funcTest(params) {
    return params;
}
funcTest([1, 2, 3, 4]);
// 原型
// new 
// type
var tBoolean = true;
var tNumber = 3;
var tString = 'second';
var tStingES6 = "good man " + tString;
var tList = [1, 2, 3];
var tListArray = [1, 3, 3, 4];
var tListArrayOther = [1, "2", { a: 3 }];
var color;
(function (color) {
    color[color["Red"] = 0] = "Red";
    color[color["Green"] = 1] = "Green";
    color[color["Blue"] = 2] = "Blue";
})(color || (color = {}));
var colorChoose = color.Red;
var tAny = 4;
tAny = '现在变成字符串了呦.';
console.log(tAny);
var tScoreRow = [100, 'aaaa', 20];
function voidFunc() {
    console.log('该函数没有返回值... 该函数类型为void');
}
voidFunc();
var tSomeVal = "0002151651561651";
var tValLength = tSomeVal.length;
var tValLengthAs = tSomeVal.length;
console.log(tValLengthAs);
function boy(opts) {
    console.log("this boy name is " + opts.name + ", age is " + opts.age);
}
var boyProperty = { name: 'good man', age: 22 };
boy(boyProperty);
var findFunc;
findFunc = function (s, f) {
    var _res = s.search(f);
    if (_res !== -1) {
        return true;
    }
    else {
        return false;
    }
};
console.log(findFunc('helloworld', 'ld'));
var testArray;
var Clock = /** @class */ (function () {
    function Clock(h, m) {
    }
    Clock.prototype.setTime = function (d) {
        this.currentTime = d;
    };
    return Clock;
}());
var clock = new Clock(16, 25);
var familyProperty = {};
familyProperty.name = 'xiaoming';
familyProperty.height = 199;
familyProperty.age = 22;
console.log(familyProperty);
// class && class extends
// public 公共的
// private 私有的
// protected 受保护的
// static 静态的
// abstract
var Family = /** @class */ (function () {
    function Family(fName, mName) {
        this.father = fName;
        this.mather = mName;
    }
    Family.prototype.son = function (age) {
        console.log("-> i am " + this.father + " son. i am " + age + " years old.");
    };
    return Family;
}());
var Son = /** @class */ (function (_super) {
    __extends(Son, _super);
    function Son(fName, age) {
        var _this = _super.call(this, fName) || this;
        _this.age = age;
        return _this;
    }
    Son.prototype.hi = function (age) {
        if (age === void 0) { age = this.age; }
        this.son(age);
    };
    return Son;
}(Family));
var family = new Family('F', 'M');
var sonFamily = new Son('F', 18);
console.log(family.father, family.mather, family.son);
sonFamily.hi();
// func
function tFunc(x, y) {
    return x + y;
}
console.log(tFunc(10, 22));
var tFunc2 = function (x, y) {
    return x + y;
};
console.log(tFunc2(10, 55));
function school(student) {
    var otherStudents = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        otherStudents[_i - 1] = arguments[_i];
    }
    console.log("\u8001\u540C\u5B66: " + student, "\u5176\u4ED6\u540C\u5B66: " + otherStudents.join(' '));
}
school('aa', 'bbb', 'ddd', 'cccc');
// genericity
function why(chr) {
    return chr;
}
console.log(why('string genericity'));
function whyGenericityArray(a) {
    return a[0];
}
var genericity2 = function (a) { console.log("\u5F53\u524D\u6570\u7EC4\u7B2C\u4E00\u9879\u4E3A" + a[0]); return a[0]; };
genericity2([11, 1]);
function createArray(length, value) {
    var result = [];
    for (var i = 0; i < length; i++) {
        result[i] = value;
    }
    return result;
}
var resArray = createArray(3, 'yyy');
console.log(resArray);
// more type genericity
function createMoreType(tuple) {
    var tu1 = tuple[1];
    var tu2 = tuple[0];
    return tu1;
}
var resArrayMore = createMoreType([7, 'seven']);
console.log(resArrayMore);
function createOneType(tuple) {
    var tu1 = tuple[1];
    var tu2 = tuple[0];
    return tu1 + tu2;
}
var restArray3 = createOneType([2222, 'seven']);
console.log(restArray3);
var threeFunc = function (a) {
    return a[0];
};
var generInterfaceTwo = function (a) {
    return a[0];
};
console.log(generInterfaceTwo([11, 22, 33]));
function whyGenericity(chr) {
    console.log(typeof chr);
    return chr;
}
function whyGenericityTwo(chr) {
    console.log(chr.length, '传过来的长度.');
    return chr;
}
var num = whyGenericity;
console.log(num(10));
console.log(whyGenericityTwo("999999"));
// enum
var familyAge;
(function (familyAge) {
    familyAge[familyAge["father"] = 33] = "father";
    familyAge[familyAge["mather"] = 22] = "mather";
    familyAge[familyAge["son"] = 10] = "son";
    familyAge[familyAge["daughter"] = 11] = "daughter";
    familyAge[familyAge["fatherNameLength"] = 'xiaoming'.length] = "fatherNameLength";
})(familyAge || (familyAge = {}));
console.log(familyAge[familyAge.father] + ' age is ' + familyAge.father);
var max = 3;
var test = 5;
if (test !== max) {
    console.log('不知道.');
}
// example class genericity extends
var BeeKeeper = /** @class */ (function () {
    function BeeKeeper() {
    }
    return BeeKeeper;
}());
var ZooKeeper = /** @class */ (function () {
    function ZooKeeper() {
    }
    return ZooKeeper;
}());
var Animal = /** @class */ (function () {
    function Animal() {
    }
    return Animal;
}());
var Bee = /** @class */ (function (_super) {
    __extends(Bee, _super);
    function Bee() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Bee;
}(Animal));
var Lion = /** @class */ (function (_super) {
    __extends(Lion, _super);
    function Lion() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Lion;
}(Animal));
function findKeeper(a) {
    return a.prototype.keeper;
}
var keeper = findKeeper(Lion);
router.get('/', function (req, res) {
    var privatePer = new Person();
    privatePer.name = 'djkloop';
    privatePer.age = 23;
    privatePer.labels = ['叼的不行', '颜值逆天', '年轻多金'];
    privatePer.wives = ['-', '==', '---'];
    privatePer.contact = ['北京别墅', 2];
    privatePer.saveMonth = false;
    privatePer.other = '牛逼的人';
    privatePer.hello();
    question(privatePer.answer());
    somefunc();
    var otherLen = privatePer.other.length;
    console.log(otherLen);
    res.status(200).json({
        message: '后台代码加载成功...'
    });
});
module.exports = router;
